package com.example.pattern.chain;

/**
 * 应用
 *
 * @author FM_南风
 * @date 2024/7/5
 */
public class ChainClient {
    public static void main(String[] args) {
        // 创建处理器对象
        Handler handler1 = new ConcreteHandler1();
        Handler handler2 = new ConcreteHandler2();
        Handler handler3 = new ConcreteHandler3();

        // 设置处理链
        handler1.setSuccessor(handler2);
        handler2.setSuccessor(handler3);

        // 创建不同级别的请求
        Request request1 = new Request(2);
        Request request2 = new Request(5);

        // 处理请求
        handler1.handleRequest(request1); // 输出 ConcreteHandler2 处理请求
        handler1.handleRequest(request2); // 输出 所有处理器均不能处理该请求
    }
}
